#/usr/bin/python
#coding:utf-8

import MySQLdb

db = "test_py"
table = "users"
users = { 'john':1000, 'larry':1001, 'mary':1002, 'lili':1003, 'lilei':1004 }


con = MySQLdb.connect(user="root")
cur = con.cursor()
cur.execute("DROP DATABASE if exists test_py")
cur.execute("CREATE DATABASE `test_py` /*!40100 DEFAULT CHARACTER SET utf8 */;")
cur.execute("use test_py")
cur.execute("CREATE TABLE users(login VARCHAR(8), uid INT)")
for login, uid in users.items():
    cur.execute("INSERT INTO users VALUES(%s,%s)",(login,uid))
con.commit()
con.close()
